import os
import shutil

gen = os.walk(".\\Jishi")

while True:

    try:

        info = next(gen)
        #print(info)

    except StopIteration:
        
        print('__pycache__文件夹删除完成')

        break

        
    else:

        if '__pycache__' in info[1]:

            path = os.path.join(info[0],'__pycache__')

            #print(path)

            shutil.rmtree(path)


    

    
